package com.yijumao.controller;

import com.yijumao.entity.User;
import com.yijumao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author konley
 * @date 2020-10-26 21:01
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("login")
    public String login(User user, HttpSession session){
        User user1 = userService.login(user);
        if(user1!=null){
            session.setAttribute("user",user1);
            return "redirect:/file/showAll";
        }else{
            return "redirect:/login";
        }
    }
}
